package com.zdp.chat.enums;

/**
 * redis key
 *
 * @author Haoran Chen
 * @since 2023/12/05
 */
public class RedisKeyConstant {

    /**
     * 分布式锁获取锁超时时间，单位秒
     */
    public static int TIME_OUT = 2;

    /**
     * 分布式加锁key前缀
     */
    public static final String LOCK_KEY = "hf:lock:key:";

    /**
     * 消息主题key
     */
    public static final String MSG_TOPIC = "hf:chat:msg:";

    /**
     * room - user + time =>房间所有用户+用户最后活跃时间
     */
    public static final String ROOM_USER_INFO= "hf:chat:room:roomId_%s";

    /**
     *  群聊房间信息
     */
    public static final String ROOM_INFO = "hf:chat:room:act_%s";

    /**
     * 用户房间头像
     */
    public static final String USER_INFO = "hf:chat:info:user_%s";

    /**
     * 用户所在房间的最后活跃时间
     */
    public static final String USER_ROOM_INFO = "hf:chat:user:userId_%s";

    /**
     *获取key
     *
     * @param key   key
     * @param objects   参数
     * @return  结果
     */
    public static String getKey(String key, Object... objects) {
        return String.format(key, objects);
    }

}
